import request from '@/utils/request'


// 新增登记
export function add(data) {

  return request({
    url: '/contract/add',
    method: 'post',
    data: data
  })
}

// 增加回款
export function addInvoiceForm(data) {

  return request({
    url: '/contract/addInvoiceForm',
    method: 'post',
    data: data
  })
}
// 修改回款金额
export function editInvoiceAmount(data) {
  return request({
    url: '/invoice/editInvoiceAmount',
    method: 'post',
    data: data
  })
}

// 修改登记
export function update(data) {

  return request({
    url: '/contract/update',
    method: 'post',
    data: data
  })
}

// 查询
export function Clientlist(){
  console.log("查询后台")
  return request({
    url: '/contract/clientlist',
    method: 'get',
  })
}

// 查询
export function queryReturnValue(query){

  return request({
    url: '/contract/queryReturnValue',
    method: 'get',
    params: query
  })
}

// 查询
export function list(query){
  return request({
    url: '/invoice/list',
    method: 'get',
    params: query
  })
}


export function queryAvailableAmountByInvoiceId(invoiceId){
  console.log("查询可开票金额")
  console.log(invoiceId)
  return request({
    url: '/invoice/queryAvailableAmountByInvoiceId',
    method: 'get',
    params: { invoiceId }
  })
}

// 修改定时任务调度
export function updateContract(data) {
  return request({
    url: '/contract/job',
    method: 'put',
    data: data
  })
}

// 删除定时任务调度
export function delContract(contractCode) {
  console.log("调用了删除")
  return request({
    url: '/contract/' + contractCode,
    method: 'delete'
  })
}

// 任务状态修改
export function changeJobStatus(jobId, status) {
  const data = {
    jobId,
    status
  }
  return request({
    url: '/monitor/job/changeStatus',
    method: 'put',
    data: data
  })
}


// 定时任务立即执行一次
export function runJob(jobId, jobGroup) {
  const data = {
    jobId,
    jobGroup
  }
  return request({
    url: '/monitor/job/run',
    method: 'put',
    data: data
  })}
